package huawei.test;

import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        String str = buf.readLine();
        String linkContent = buf.readLine();
        String[] ss = str.split(" ");
        String[] contents = linkContent.split(" ");
        //创建链表
        int n = Integer.parseInt(ss[0]);
        int m = Integer.parseInt(ss[1]);
        Node head = new Node(Integer.parseInt(contents[0]), null);
        Node temp = head;
        for(int i = 2; i <= n; i++){
            temp.next = new Node(Integer.parseInt(contents[i - 1]), null);
            temp = temp.next;
        }
        Node last = head;
        temp = head;
        for(int i = 2; i <= m; i++){
            last = temp;
            temp = temp.next;
        }
        last.next = temp.next;
        temp = head;
        StringBuilder sb = new StringBuilder();
        while(temp != null){
            sb.append(temp.val).append(' ');
            temp = temp.next;
        }
        sb.deleteCharAt(sb.length() - 1);
        System.out.print(sb.toString());

    }
}
class Node{
    int val;
    Node next;

    public Node(int val,Node next){
        this.val = val;
        this.next = next;
    }
}

